package com.hh.servlet.wxpay;

import java.io.IOException;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.hh.servlet.wxpay.util.ResultNotify;

/**
 * Servlet implementation class Notify
 */
@WebServlet("/PayNotify")
public class PayNotify extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public PayNotify() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		 ResultNotify resultNotify = new ResultNotify(request, response);
	        Map<String, String> result_map=null;
			try {
				result_map = resultNotify.ProcessNotify();
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
//	         saveorderService.updateNotifyOrder(pd,result_map);
	        //根据微信支付回调的参数（订单号） 修改状态
			if(result_map!=null){
				String out_trade_no = result_map.get("OUT_TRADE_NO");
				System.out.println(out_trade_no+"----------------完成支付回调--------------------------");
			}else{
				System.out.println("回调失败");
			}
	}

}
